<template>
  <div>
    <el-button @click="closeDrawer()" size="small" type="primary">导入模板下载</el-button>
    <div style="margin:20px 0"></div>
    <importFile :title="'导入'" :actionUrl="urls" @close="closeHandler" />

    <div style="height:47px;"></div>
  </div>
</template>
<script>
import { downloadColor } from '@/api/omSale/vehicleParameters/vehicleColour/index.js';
import { excelList1 } from '@/api/omSaleP/vehicleParameters/vehicleMaterials/index.js';
import { downloadUrl,exportExcelFile } from '@/utils'
import moment from 'moment'
export default {
  data() {
    return {
      // urls: '/api/basedata/vehicleProduct/productInfo/productImportFromExcel',
      urls: '/api/basedata/vehicleProduct/productInfo/productImportFromExcel1',
      fetchParams: {

      },
      fetchApi: () => { },
    }
  },
  methods: {
    closeDrawer(type) {
      this.$confirm('是否将Excel表格保存至本地文件夹?', '提示', {
        confirmButtonText: '下载',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {


        let json = this.fetchParams;
        this.exportLoading = true;

        excelList1(json)
          .then(response => {
            exportExcelFile(response.data, '整车物料导入');
            this.exportLoading = false;
          })
          .catch(err => {
 
          });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    },
    closeHandler(val) {
 
      if (val.length > 0 && val[0].url.result == "success") {
        this.$emit('close', val[0].url.resultList)
      } else {
        this.$emit('close', [])
      }
    },

  },
}

</script>
